Trò chơi đua xe động vật trong UNITY Engine
114.939 lượt xem;
1 using UnityEngine;
2 using System.Collections;
3
4 public class ActionDelay : Action {
5
6 private float duration, time;
7 private bool complete;
8
9 public ActionDelay(float duration) {
10 this.duration = duration;
11 }
12
13 public override void restart()
14 {
15 base.restart();
16 time = 0;
17 complete = false;
18 }
19
20 public override bool Act(float delta)
21 {
22 if (complete) return true;
23 time += delta;
24 complete = time >= duration;
25 return complete;
26 }
27 }
2 using System.Collections;
3
4 public class ActionDelay : Action {
5
6 private float duration, time;
7 private bool complete;
8
9 public ActionDelay(float duration) {
10 this.duration = duration;
11 }
12
13 public override void restart()
14 {
15 base.restart();
16 time = 0;
17 complete = false;
18 }
19
20 public override bool Act(float delta)
21 {
22 if (complete) return true;
23 time += delta;
24 complete = time >= duration;
25 return complete;
26 }
27 }